/*
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms
 */

package com.zjm.zdk.util;

import java.util.*;
import java.util.function.Consumer;

public class MyHashMap<K,V> {


    /**
     * Basic hash bin node, used for most entries.  (See below for
     * TreeNode subclass, and in LinkedHashMap for its Entry subclass.)
     */
    static class Node<K,V> implements Map.Entry<K,V> {
        final int hash;
        final K key;
        V value;
        Node<K,V> next;

        Node(int hash, K key, V value, Node<K,V> next) {
            this.hash = hash;
            this.key = key;
            this.value = value;
            this.next = next;
        }

        public final K getKey()        { return key; }
        public final V getValue()      { return value; }
        public final String toString() { return key + "=" + value; }

        public final int hashCode() {
            return Objects.hashCode(key) ^ Objects.hashCode(value);
        }

        public final V setValue(V newValue) {
            V oldValue = value;
            value = newValue;
            return oldValue;
        }

        public final boolean equals(Object o) {
            if (o == this)
                return true;
            if (o instanceof Map.Entry) {
                Map.Entry<?,?> e = (Map.Entry<?,?>)o;
                if (Objects.equals(key, e.getKey()) &&
                        Objects.equals(value, e.getValue()))
                    return true;
            }
            return false;
        }
    }
    void clear() {}
    final boolean contains(Object o) {
        return o == null;
    }

    public String getOut() {
        return "out";
    }

    final class KeySet extends AbstractSet<K> {
        public final int size()                 { return 0; }
        public final void clear()               { MyHashMap.this.clear(); }
        public final Iterator<K> iterator()     { return null;}
        public final boolean contains(Object key) {
            return MyHashMap.this.contains(key);
        }

        public String getOut() {
            return MyHashMap.this.getOut();
        }
        public final boolean remove(Object key) {
           return false;
        }
        public final Spliterator<K> spliterator() {
            return null;
        }
        public final void forEach(Consumer<? super K> action) {

        }
    }
}













